class UserProfile {
  ///年龄
  final int age;

  ///头像
  final String avatar;

  ///创建时间
  // final String createdTime;

  ///用户ID
  final int id;

  ///最后一次登录时间
  final String lastLogin;

  ///昵称
  final String nickName;

  ///真实姓名
  final String realName;

  ///性别，男：1，女：2
  final dynamic sex;

  ///更新时间
  // final String updateTime;

  ///用户名
  final String username;

  /// 生日
  final String birthday;

  /// 是否设置了密码
  final bool hasPassword;

  UserProfile({
    this.age = 0,
    required this.avatar,
    // this.createdTime = '',
    this.id = 0,
    this.lastLogin = '',
    this.nickName = '',
    this.realName = '',
    this.sex = 0,
    // this.updateTime = '',
    this.username = '',
    this.birthday = '',
    this.hasPassword = false,
  });

  UserProfile copyWith(
          {int? age,
          String? avatar,
          String? createdTime,
          int? id,
          String? lastLogin,
          String? nickName,
          String? realName,
          int? sex,
          String? updateTime,
          String? username,
          bool? hasPassword,
          String? birthday}) =>
      UserProfile(
        age: age ?? this.age,
        avatar: avatar ?? this.avatar,
        // createdTime: createdTime ?? this.createdTime,
        id: id ?? this.id,
        lastLogin: lastLogin ?? this.lastLogin,
        nickName: nickName ?? this.nickName,
        realName: realName ?? this.realName,
        sex: sex ?? this.sex,
        // updateTime: updateTime ?? this.updateTime,
        username: username ?? this.username,
        birthday: birthday ?? this.birthday,
        hasPassword: hasPassword ?? this.hasPassword,
      );

  factory UserProfile.fromJson(Map<String, dynamic> json) => UserProfile(
        age: json["age"] ?? 0,
        avatar: json["avatar"],
        // createdTime: json["created_time"] ?? 0,
        id: json["id"] ?? 0,
        lastLogin: json["last_login"] ?? '',
        nickName: json["nick_name"] ?? '',
        realName: json["real_name"] ?? '',
        sex: json["sex"] ?? 0,
        // updateTime: json["update_time"] ?? '',
        username: json["username"] ?? '',
        birthday: json["birthday"] ?? '',
        hasPassword: json["has_password"] ?? false,
      );

  Map<String, dynamic> toJson() => {
        "age": age,
        "avatar": avatar,
        // "created_time": createdTime,
        "id": id,
        "last_login": lastLogin,
        "nick_name": nickName,
        "real_name": realName,
        "sex": sex,
        // "update_time": updateTime,
        "username": username,
        "birthday": birthday,
        "has_password": hasPassword,
      };
}
